package com.czf.testmodule.time.timer;


import cn.hutool.core.date.DateTime;
import lombok.extern.slf4j.Slf4j;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @author zfChen
 * @create 2022/6/7 9:57
 */
@Slf4j
public class TimerDemo {

    public static void main(String[] args) {
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                log.info("当前时间{}线程名称{}", DateTime.now(), Thread.currentThread().getName());
            }
        };

        log.debug("当前的时间{}线程名称{}", DateTime.now(), Thread.currentThread().getName());

        Timer timer = new Timer("TimerDemo");
        timer.schedule(task,2000);
    }

}
